package com.zhida.jiyangcenter.utils

import android.content.Context
import chooongg.base.utils.logE
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.amap.api.location.AMapLocationListener
import kotlinx.android.synthetic.main.fragment_main_store.*

fun getLocation(context:Context,aMapLocationListener: ((AMapLocation) -> Unit)?):AMapLocationClient{
     return AMapLocationClient(context).apply {
        setLocationOption(
            AMapLocationClientOption()
                .setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy)
                .setOnceLocation(true)
                .setOnceLocationLatest(true)
                .setNeedAddress(true)
                .setLocationCacheEnable(false)

        )
        setLocationListener {aMapLocationListener?.invoke(it)}
        startLocation()
    }
}